package mysql

import (
	"github.com/astaxie/beego/orm"
)

type Category struct {
	Id       string `orm:"Column(Id)"`
	Name     string `orm:"Column(Name)"`
	KeyName  string `orm:"Column(KeyName)"`
	Data     string `orm:"Column(Data)"`
	ParentId string `orm:"Column(ParentId)"`
}

func (u *Category) TableName() string {
	return CategoryTBName()
}

func FindCategoryByName(name string) (*Category, error) {
	o := orm.NewOrm()
	category := Category{}
	err := o.Raw("SELECT * FROM S_Category WHERE `Name`=?", name).QueryRow(&category)
	return &category, err
}
